﻿@using ECG.Utility
@using ECG.WebUI.CustomHelpers
@using ECG.WebUI.Models
@model List<ECG.Common.ProductRateByCateTopListPagingDto>

@{
    @*if (ViewBag.CurrentPage>1)
        {
            <div class="pItem-pagging-other">
                <a href="javascript:void(0);" rel="nofollow">Trang @ViewBag.CurrentPage</a>
            </div>
        }*@
    if (Model.Any())
    {
        <div>
            <span class="showRecord-@ViewBag.CurrentPage">có <span id="totalRecord-@ViewBag.CurrentPage">@ViewBag.TotalRecod</span> sản phẩm</span>
            <input type="hidden" class="hidRecordByPage" value="@ViewBag.RecordByPage" />
        </div>
        <ul class="listp ul clearfix">

            @foreach (var item in Model)
            {
                var pDetailLink = Url.Action("Index", "ProductDetail", new { productId = item.Id, productName = StringUtil.RemoveSpecialCharactersVn(item.Name) });
                <li>
                    <div class="pItem">
                        <a href="@pDetailLink" class="pItem-lnkImg">
                            @if (item.PromotionPrice > 0)
                            {
                                <span class="pItem-per">-@item.DiscountPercentage.ToString("#.#")<i>%</i></span>
                            }
                            <img src="@item.ImagePath.ImagePathThumb(135, 135)" width="135" height="135" alt="@item.Name" class="lzLoading">
                        </a>
                        <div class="pItem-info">
                            <div style="line-height: 13px; margin-top: 5px;">
                                @{
                            string StarPercent = "0";
                            if (item.AverageRate > 0)
                            {
                                StarPercent = (Convert.ToDouble(item.AverageRate) * 100 / 5).ToString("#.#").Replace(',', '.');
                            }
                                }
                                <span class="itm-ratStars inlineBlocka"><span style="width: @StarPercent%;" class="itm-ratStars itm-ratRating"></span></span>
                            </div>
                            <h2>
                                <a href="@pDetailLink">@item.Name</a>
                            </h2>
                            @if (item.PromotionPrice > 0)
                            {
                                <p class="pItem-PriceOld">
                                    @item.Price.ToString("##,###,###") đ
                                </p>
                                <p class="pItem-PriceNew">
                                    @item.PromotionPrice.ToString("##,###,###") <strong>đ</strong>
                                    <a href="javascript:void(0);" class="fbComment">Bình luận</a>
                                </p>
                            }
                            else
                            {
                                <p class="pItem-PriceNew">
                                    @item.Price.ToString("##,###,###") <strong>đ</strong>
                                    <a href="javascript:void(0);" class="fbComment">Bình luận</a>
                                </p>
                            }

                        </div>
                    </div>
                </li>
            }
        </ul>
    }
}